package com.normalsys.live.controller;

import com.normalsys.live.base.util.token.TokenUtil;
import com.normalsys.live.bean.*;
import com.normalsys.live.entity.UserForm;
import com.normalsys.live.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * Created with IntelliJ IDEA.
 * User: 刘天宇
 * Date: 2018/7/16
 * Time: 20:38
 * Description: 用户管理
 */
@RestController
@Slf4j
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 添加form
     * @param userFormParamBean
     * @param req
     * @return
     */
    @PostMapping("/addForm")
    public UserForm addForm(@RequestBody UserFormParamBean userFormParamBean, HttpServletRequest req) {
        Long userId = TokenUtil.getUserId(req);
        userFormParamBean.setUserId(userId);
        return userService.addForm(userFormParamBean);
    }

}
